﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using SLRTHackathon.DataModels;

namespace SLRTHackathon.Views
{
    public partial class AddCustomDependencyPage : PhoneApplicationPage
    {
        public AddCustomDependencyPage()
        {
            InitializeComponent();
        }

        private void AddDependencyButton_Click(object sender, RoutedEventArgs e)
        {
            //Confirm there is some text in the text box.
            if (NameTextBlock.Text.Length > 0)
            {
                //Create a new to-do item.
                CustomDependency newCustomDependency = new CustomDependency
                {
                    Name = NameTextBox.Text,
                    Description = DescriptionTextBox.Text,
                    StartDate = StartDateDatePicker.Value.Value,
                    EndDate = EndDateDatePicker.Value.Value,
                    NumberOfDaysBeforeEndDate = Int32.Parse(DaysBeforeEndDateTextBox.Text),
                    Car = CarHelperPage.CurrentCar
                };

                //Add the item to the ViewModel.
                App.ViewModel.AddCustomDependency(newCustomDependency);
                NavigationService.Navigate(new Uri("/Views/CarHelperPage.xaml", UriKind.RelativeOrAbsolute));
            }
        }
    }
}